#include<stdio.h>
#include"process.h"
#include<time.h>
#include<stdlib.h>

typedef void(*callback_t)(double, double);
double speed = 1.0;
double SpeedFloat(double start, double range)
{
    int int_of_range = (int)range;
    return start + rand()%int_of_range + (range - int_of_range);
}

void DownLoad(double total, callback_t cb)
{
    srand(time(NULL));
    
    double cur = 0.0;

    while(1)
    {
        if(cur > total)
        {
            cur = total;
            cb(total, cur);
            break;
        }
        cb(total, cur);
    
        cur += SpeedFloat(speed, 30.5);
        usleep(30000);
    }
}
int main()
{
    // Process();
    DownLoad(2000.0, FlushProcess);
    return 0;
}
